package Bsepuer.command;

import java.util.HashMap;
import java.util.Map;

import Bsepuer.command.impl.ExitCommand;
import Bsepuer.command.impl.HelpCommand;
import Bsepuer.command.impl.loginCommand;
import Bsepuer.command.impl.registerCommand;

public class SystemCommandFactory extends CommandFactory{
	
	private static Map<CommandCode,Class<? extends Command>> systemCommandMap=new HashMap<>();
	
	static{
		systemCommandMap.put(CommandCode.EXIT, ExitCommand.class);
		systemCommandMap.put(CommandCode.HELP, HelpCommand.class);
		systemCommandMap.put(CommandCode.LOGIN, loginCommand.class);
		systemCommandMap.put(CommandCode.REGISTER, registerCommand.class);
	}
	
	
	
          public Command buildCommand(CommandCode cmdCode){
        	  
        	Class<?extends Command>cmdClass =systemCommandMap.get(cmdCode);
        	
        	if(cmdClass!=null){
        		try {
					return cmdClass.newInstance();
				} catch (InstantiationException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				}
        	}   	  
			return null;
   	  
          }
}
